import requests

# r = requests.get("https://www.baidu.com")
# # 打印状态码
# print(r.status_code)
# # 打印响应体
# print(r.text)
# # print(r.json())
# #打印响应头
# print(r.headers)

# get = requests.get("https://www.baidu.com/")
# post = requests.post("https://www.baidu.com/")
#
# req_get = requests.request("GET", "https://www.baidu.com/")
# # req_post = requests.request("POST", "https://www.baidu.com/")
# # 传递参数时指定参数
# req_post = requests.request(method="POST", url="https://www.baidu.com/")
# # req_post = requests.request(url="https://www.baidu.com/", method="POST")
#
# print("get:", get)
# print("post:", post)
# print("req_get:", req_get)
# print("req_post:", req_post)


# # 请求博客详情页接口
# # 必须要先登录---在请求头添加用户登录凭证(User_token_header)
#
# # url = "http://8.137.19.140:9090/blog/getBlogDetail?blogId=158477"
# # 这里的get请求， url拼接的参数也可以单独拿下来写
# url = "http://8.137.19.140:9090/blog/getBlogDetail?"
# param = {
#     "blogId":158477
# }
#
# # 定义请求头
# header = {
#     "User_token_header":"eyJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwidXNlck5hbWUiOiJ6aGFuZ3NhbiIsImV4cCI6MTc2MTYzOTQxOX0.uSpOKp2zYUxhJtBbsqcn2l8irJPiDS6x9qD1TauGgBk"
# }
# r = requests.request(method="GET", url = url, params=param, headers=header)
# print(r.json())

# 博客系统登录接口
# POST 表单格式

url = "http://8.137.19.140:9090/user/login"

data = {
    "username":"zhangsan",
    "password":"123456"
}

r = requests.request(method="POST", data=data, url = url)
print(r.json())




















